/**
 * @file   ManDocs.h
 * @brief   
 ****************************************************************************
 * @version 0.6.030 $Id: ManDocs.h 2863 2010-08-07 04:28:58Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/**
 * @class   wosh::xtended::ManItem
 * @brief   
 *
 *
 *
 ****************************************************************************
 * @version 0.6.030
 * @author  Alessandro Polo
 ****************************************************************************/
/**
 * @class   wosh::xtended::ManItemProperty
 * @brief   
 *
 *
 *
 ****************************************************************************
 * @version 0.6.030
 * @author  Alessandro Polo
 ****************************************************************************/
/**
 * @class   wosh::xtended::ManSection
 * @brief   
 *
 *
 *
 ****************************************************************************
 * @version 0.6.030
 * @author  Alessandro Polo
 ****************************************************************************/
/**
 * @class   wosh::xtended::ManPage
 * @brief   
 *
 *
 *
 ****************************************************************************
 * @version 0.6.030
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Xtended_ManDocs_H__
 #define __WOSH_Xtended_ManDocs_H__
 
 #include <woshDefs.h>
 #include <core/Object.h>
 #include <core/Variant.h>
 #include <core/Containers.h>
 #include <core/Utilities.h>


namespace wosh {
 namespace xtended {



struct ManReference {
	std::string type;
	std::string name;
};

struct ManKeyword {
	std::string name;
};


class ManItem : public virtual ISerializable
 {
	WOSH_SERIALIZABLE(wosh::xtended::ManItem)
	WOSH_COMPARE_RTTI(wosh::xtended::ManItem)

	public:
		ManItem() {
		 }
		ManItem( const ManItem& m ) {
			*this = m;
		 }
		virtual ~ManItem() { }


/** @name Getters
 * @{
 ******************************************************************************/
 	public:
		const std::string& getName() const					{ return this->name; }
		std::string& getName()								{ return this->name; }

		const std::string& getDescription() const			{ return this->description; }
		std::string& getDescription()						{ return this->description; }

		const std::vector<ManReference>& getReferences() const	{ return this->references; }
		std::vector<ManReference>& getReferences()				{ return this->references; }

		const std::vector<ManKeyword>& getKeywords() const		{ return this->keywords; }
		std::vector<ManKeyword>& getKeywords()					{ return this->keywords; }

//@}
/** @name Setters
 * @{
 ******************************************************************************/
 	public:
		void setName( const std::string& value )			{ this->name = value; }
		void setDescription( const std::string& value )		{ this->description = value; }

//@}
/** @name Operators Overloading
 * @{
 ******************************************************************************/
	public:
		ManItem& operator=(const ManItem& m);

		bool operator==(const ManItem &other) const;
		bool operator!=(const ManItem &other) const			{ return !(*this == other);  }

//@}
/** @name Serialization interface
 * @{
 ******************************************************************************/
	public:
		virtual std::string toString() const;
		virtual bool updateHash( DataHashContext* hash_context ) const;
//@}
	protected:
		std::string name;
		std::string description;
		std::vector<ManReference> references;
		std::vector<ManKeyword> keywords;

}; // class def



class ManItemProperty : public ManItem
 {
	WOSH_SERIALIZABLE(wosh::xtended::ManItemProperty)

	public:
		ManItemProperty() : ManItem() { }
		virtual ~ManItemProperty() { }

	public:
		const wosh::Variant& getValueDefault() const		{ return this->valueDefault; }
		wosh::Variant& getValueDefault()					{ return this->valueDefault; }

	public:
		virtual std::string toString() const;

	public:
		wosh::Variant valueDefault;

}; // class def



class ManSection : public ManItem
 {
	WOSH_SERIALIZABLE(wosh::xtended::ManSection)

	typedef MapT<std::string, ManItem*> tStrManItemMap;


	public:
		ManSection() : ManItem() { }
		virtual ~ManSection() { }

		const tStrManItemMap& getItem() const	{ return this->items; }
		tStrManItemMap& getItem()				{ return this->items; }

		virtual std::string toString() const;

	protected:
		tStrManItemMap items;

}; // class def









class ManPage : public ManItem
 {
	WOSH_SERIALIZABLE(wosh::xtended::ManPage)

	typedef MapT<std::string, ManSection*> tStrManSectionMap;

	public:

		ManPage() : ManItem() {
			this->language = "en-GB";
		}

		ManPage( const ManPage& m ) : ManItem(m) {
			this->language = "en-GB";
		}

		virtual ~ManPage() { }


/** @name Getters
 * @{
 ******************************************************************************/
 	public:
		const std::string& getLanguage() const			{ return this->language; }

		const std::string& getXmlSource() const			{ return this->xmlSource; }

		const tStrManSectionMap& getSections() const	{ return this->sections; }
		tStrManSectionMap& getSections()				{ return this->sections; }


//@}
/** @name Setters
 * @{
 ******************************************************************************/
 	public:
		void setLanguage( const std::string& value )	{ this->language = value; }
		
		void setVersion( double value )					{ this->version = value; }

		void setXmlSource( const std::string& value )	{ this->xmlSource = value; }
//@}
/** @name Serialization interface
 * @{
 ******************************************************************************/
	public:
		virtual std::string toString() const;
//@}
	protected:
		std::string language;
		std::string xmlSource;
		double version;

		tStrManSectionMap sections;


}; // class def


 }; // namespace xtended
}; // namespace wosh

#endif //__WOSH_Xtended_ManDocs_H__
